<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.text.DecimalFormat, java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">

  <title>银行卡转账</title>
  <script type="text/javascript">
    function showAlert() {

      alert("您的验证码是：666" );
    }
  </script>

  <style>
    body {
      background-color: #f2f2f2;
    }

    h1, label, input[type=submit], select {
      color: #333;
    }

    form {
      border: 2px solid #333;
      padding: 20px;
      border-radius: 10px;
      background-color: #fff;
      width: 400px;
      margin: 0 auto;
      box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
    }

    label {
      display: block;
      margin-bottom: 10px;
    }

    input[type=text], input[type=number], select {
      border: 1px solid #ddd;
      border-radius: 5px;
      padding: 5px;
      font-size: 16px;
      margin-bottom: 10px;
      width: 100%;
    }

    input[type=submit] {
      background-color: #333;
      color: #fff;
      border: none;
      padding: 10px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 18px;
      margin-top: 10px;
      width: 100%;
    }

    .error-msg {
      color: red;
      font-size: 14px;
      margin-top: 5px;
    }

  </style>
</head>
<body>
<h1>银行卡转账</h1>
<form action="/TransferServlet" method="post">
  <input type="hidden" name="action" value="transfer" />
  <label>选择付款账号:</label>
  <select name="fromAccountId">
    <c:forEach items="${user.userCards}" var="UserCard">
      <option>${UserCard.cid}</option>
    </c:forEach>
  </select><br>
  <label for="toAccount">转入账户：</label>
  <input type="number" name="toAccountId" id="toAccount" required><br>
  <label for="amount">转账金额：</label>
  <input type="number" name="amount" id="amount" required><br>
  <button onclick="showAlert()" >点击发送验证码</button>
  <label for="code">请输入验证码：</label>
  <input type="number" name="code" id="code" required><br>
  <%--格式化金额，保留两位小数--%>
  <%
    DecimalFormat df = new DecimalFormat("#.00");
    String errorMsg = (String) request.getAttribute("errorMsg");
    if (errorMsg != null && !errorMsg.equals("")) {
  %>
  <span class="error-msg"><%= errorMsg %></span>
  <%
    }
  %>
  <input type="submit" value="转账">
</form>


</body>
</html>